package com.nikkerball.unit;

import com.nikkerball.interpreter.BasicInterpreter;
import com.nikkerball.interpreter.Interpreter;
import com.nikkerball.interpreter.JouleInterpreter;

import java.math.BigDecimal;

import static com.nikkerball.unit.Legend.approximately;
import static com.nikkerball.unit.Legend.exactly;
import static com.nikkerball.unit.MathHelper.powerOfTen;

/**
 * User: Marius
 * Date: 12-Feb-2010
 * Time: 10:04:41
 */
@SuppressWarnings({"MagicNumber", "UnusedDeclaration"})

public enum EnergyUnit implements Unit {

    barrelOfOil("org.nikkerball.unit.barrelOfOilEquivalent", "boe", 6.12 * powerOfTen(9), approximately),
    britishThermalUnitISO("org.nikkerball.unit.britishThermalUnitISO", "BTU (ISO)", 1.0545 * powerOfTen(3), exactly),
    britishThermalUnitIT("org.nikkerball.unit.britishThermalUnitIT", "BTU (IT)", 1.05505585262 * powerOfTen(3),
            exactly),
    britishThermalUnitMean("org.nikkerball.unit.britishThermalUnitMean", "BTU (Mean)", 1.05587 * powerOfTen(3),
            approximately),
    britishThermalUnitThermochemical("org.nikkerball.unit.britishThermalUnitThermochemical", "BTU (Thermochemical)",
            1.054350 * powerOfTen(3), approximately),
    britishThermalUnit39F("org.nikkerball.unit.britishThermalUnit39F", "BTU (39 F)", 1.05967 * powerOfTen(3),
            approximately),
    britishThermalUnit59F("org.nikkerball.unit.britishThermalUnit59F", "BTU (59 F)", 1.054804 * powerOfTen(3), exactly),
    britishThermalUnit60F("org.nikkerball.unit.britishThermalUnit60F", "BTU (60 F)", 1.05468 * powerOfTen(3),
            approximately),
    britishThermalUnit63F("org.nikkerball.unit.britishThermalUnit63F", "BTU (63 F)", 1.0546 * powerOfTen(3),
            approximately),
    calorieIT("org.nikkerball.unit.calorieIT", "cal (IT)", 4.1868, exactly),
    calorieMean("org.nikkerball.unit.calorieMean", "cal (Mean)", 4.19002, approximately),
    calorieThermochemical("org.nikkerball.unit.calorieThermochemical", "cal (Thermochemical)", 4.184, exactly),
    calorie3_98C("org.nikkerball.unit.calorie3.98C", "cal (3.98C)", 4.2045, approximately),
    calorie15C("org.nikkerball.unit.calorie15C", "cal (15C)", 4.1855, exactly),
    calorie20C("org.nikkerball.unit.calorie20C", "cal (20C)", 4.1819, approximately),
    celsiusHeatUnitIT("org.nikkerball.unit.celsiusHeatUnitIT", "CHU (IT)", 1.899100534716 * powerOfTen(3), exactly),
    cubicCentimetreOfAtmosphere("org.nikkerball.unit.cubicCentimetreOfAtmosphere", "cc atm", 0.101325, exactly),
    standardCubicCentimetre("org.nikkerball.unit.standardCubicCentimetre", "scc", 0.101325, exactly),
    cubicFootOfAtmosphere("org.nikkerball.unit.cubicFootOfAtmosphere", "cu ft atm", 2.8692044809344 * powerOfTen(3),
            exactly),
    standardCubicFoot("org.nikkerball.unit.standardCubicFoot", "scf", 2.8692044809344 * powerOfTen(3), exactly),
    cubicFootOfNaturalGas("org.nikkerball.unit.cubicFootOfNaturalGas", "Cubic Foot Of Natural Gas",
            1.05505585262 * powerOfTen(6), exactly),
    cubicYardOfAtmosphere("org.nikkerball.unit.cubicYardOfAtmosphere", "cu yd atm", 77.4685209852288 * powerOfTen(3),
            exactly),
    standardCubicYard("org.nikkerball.unit.standardCubicYard", "scy", 77.4685209852288 * powerOfTen(3), exactly),
    electronVolt("org.nikkerball.unit.electronVolt", "eV", 1.60217733 * powerOfTen(-19), approximately),
    erg("org.nikkerball.unit.erg", "erg", powerOfTen(-7), exactly),
    footPoundForce("org.nikkerball.unit.footPoundForce", "tft lbf", 1.3558179483314004, exactly),
    footPoundal("org.nikkerball.unit.footPoundal", "tft pdl", 4.21401100938048 * powerOfTen(-2), exactly),
    gallonAtmosphereImperial("org.nikkerball.unit.gallonAtmosphereImperial", "imp gal atm", 460.63256925, exactly),
    gallonAtmosphereUS("org.nikkerball.unit.gallonAtmosphereUS", "US gal atm", 383.5568490138, exactly),
    hartreeAtomicUnitOfEnergy("org.nikkerball.unit.hartreeAtomicUnitOfEnergy", "E(h)", 4.359744 * powerOfTen(-18),
            approximately),
    horsepowerHour("org.nikkerball.unit.horsepowerHour", "hp-h", 2.684519537696172792 * powerOfTen(6), exactly),
    joule("org.nikkerball.unit.joule", "J", 1, exactly, new JouleInterpreter()),
    kiloCalorie("org.nikkerball.unit.kiloCalorie", "kcal", 4.1868 * powerOfTen(3), exactly),
    kiloWattHour("org.nikkerball.unit.kiloWattHour", "kWh", 3.6 * powerOfTen(6), exactly),
    litreAtmosphere("org.nikkerball.unit.litreAtmosphere", "l atm", 101.325, exactly),
    quad("org.nikkerball.unit.quad", "quad", 1.05505585262 * powerOfTen(18), exactly),
    rydberg("org.nikkerball.unit.rydberg", "Ry", 2.179872 * powerOfTen(-18), approximately),
    thermEC("org.nikkerball.unit.thermEC", "therm (EC)", 105.505585262 * powerOfTen(6), exactly),
    thermUS("org.nikkerball.unit.thermUS", "therm (US)", 105.4804 * powerOfTen(6), exactly),
    thermie("org.nikkerball.unit.thermie", "th", 4.186 * powerOfTen(6), exactly),
    tonOfCoalEquivalent("org.nikkerball.unit.tonOfCoalEquivalent", "TCE", 29.3076 * powerOfTen(9), exactly),
    tonOfOilEquivalent("org.nikkerball.unit.tonOfOilEquivalent", "TOE", 41.868 * powerOfTen(9), exactly),
    tonOfTNT("org.nikkerball.unit.tonOfTNT", "tTNT", 4.184 * powerOfTen(9), exactly),;

    private String name;

    private String symbol;

    private BigDecimal conversion;

    private Legend legend;

    private Interpreter interpreter;

    EnergyUnit(String name, String symbol, double conversion, Legend legend, Interpreter interpreter) {
        this(name, symbol, conversion, legend);
        this.interpreter = interpreter;
    }

    EnergyUnit(String name, String symbol, double conversion, Legend legend) {
        this.name = name;
        this.symbol = symbol;
        this.conversion = new BigDecimal(conversion);
        this.legend = legend;
        this.interpreter = new BasicInterpreter();
    }

    public Unit getBaseUnit() {
        return joule;
    }

    public String getKey() {
        return name;
    }

    public String getSymbol() {
        return symbol;
    }

    public BigDecimal getConversion() {
        return conversion;
    }

    public Interpreter getInterpreter() {
        return interpreter;
    }

    public Legend getConversionLegend() {
        return legend;
    }

}
